home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / hyperGraphPanel.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  12.5 KB  |  428 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //  Alias|Wavefront Script File
  19. //  MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //  Creation Date:  December 16, 1996
  22. //
  23. //  Description:
  24. //      This script creates a panel which has a button line and a hyper panel 
  25. //    in it.
  26. //
  27. //  Input Arguments:
  28. //      panel name
  29. //
  30. //  Return Value:
  31. //      None.
  32. //
  33.  
  34. global proc createHyperGraphPanel (string $whichPanel)
  35. //
  36. //  Description:
  37. //        Define the editors that are used in this panel.  No
  38. //        controls (widgets) are created at this point.
  39. //        Adds support for the context sensitive help menu items.
  40. //
  41. {
  42.     //  create unique names for editors based on panel name
  43.     //
  44.     string $hyperGraphEd = ($whichPanel + "HyperGraphEd");
  45.     string $nameFilter = ($hyperGraphEd + "NameFilter");
  46.  
  47.     hyperGraph
  48.         -unParent
  49.         -popupMenuScript "HyperGraphEdMenu"
  50.         $hyperGraphEd;
  51.  
  52.     if (`exists hyperUserInit`) hyperUserInit $hyperGraphEd;
  53.  
  54.     //    Add support for the Context Sensitive Help Menu.
  55.     //
  56.     addContextHelpProc $whichPanel "buildHyperGraphContextHelpItems";
  57. }
  58.  
  59. global proc initHyperGraphPanel (string $whichPanel) 
  60. //
  61. //  Description:
  62. //        Called on file -new/open.  
  63. //
  64. {
  65.     string $hyperGraphEd = ($whichPanel + "HyperGraphEd");
  66.     
  67.     hyperGraph -e -filter "" $hyperGraphEd;
  68. }
  69.  
  70. global proc addHyperGraphPanel (string $whichPanel)
  71. //
  72. //  Description:
  73. //        Add the panel to a layout.
  74. //        Parent the editors to that layout and create any other
  75. //        controls (widgets) required.
  76. //
  77. {
  78.     string $hyperGraphEd = ($whichPanel + "HyperGraphEd");
  79.  
  80.     waitCursor -state on;
  81.     
  82.     // Make sure that there is no template active
  83.     setUITemplate -pushTemplate NONE;
  84.  
  85.     // Create Menu Bar, which will use exactly the same menu entries as the popupMenu
  86.     // on the background of the hyperPanel
  87.  
  88. //    menuBarLayout hyperGraphMenu;
  89. //    setParent -menu ..;
  90.  
  91.     // If this is the first Hypergraph to be created in this session
  92.     // then get all of the options from the optionVars.
  93.     //
  94.     global int $gFirstHypergraph = 0;
  95.     if ($gFirstHypergraph == 0) {
  96.         $gFirstHypergraph = 1;  
  97.         
  98.         // Set default state for Display preferences
  99.         //
  100.         if (!`optionVar -exists hypergraphDisplayShapeNodes`) {
  101.             optionVar -intValue hypergraphDisplayShapeNodes 0;
  102.         }
  103.         if (!`optionVar -exists hypergraphDisplayInvisibleNodes`) {
  104.             optionVar -intValue hypergraphDisplayInvisibleNodes 0;
  105.         }
  106.         if (!`optionVar -exists hypergraphDisplayUnderworldNodes`) {
  107.             optionVar -intValue hypergraphDisplayUnderworldNodes 0;
  108.         }
  109.         if (!`optionVar -exists hypergraphDisplayExpressions`) {
  110.             optionVar -intValue hypergraphDisplayExpressions 0;
  111.         }
  112.         if (!`optionVar -exists hypergraphDisplayConstraints`) {
  113.             optionVar -intValue hypergraphDisplayConstraints 0;
  114.         }
  115.         if (!`optionVar -exists hypergraphDisplayDeformers`) {
  116.             optionVar -intValue hypergraphDisplayDeformers 0;
  117.         }
  118.         if (!`optionVar -exists hypergraphDisplayImage`) {
  119.             optionVar -intValue hypergraphDisplayImage 0;
  120.         }
  121.         
  122.         hyperGraph -e -showShapes `optionVar -q hypergraphDisplayShapeNodes` $hyperGraphEd;
  123.         hyperGraph -e -showInvisible `optionVar -q hypergraphDisplayInvisibleNodes` $hyperGraphEd;
  124.         hyperGraph -e -showUnderworld `optionVar -q hypergraphDisplayUnderworldNodes` $hyperGraphEd;
  125.         hyperGraph -e -showExpressions `optionVar -q hypergraphDisplayExpressions` $hyperGraphEd;
  126.         hyperGraph -e -showConstraints `optionVar -q hypergraphDisplayConstraints` $hyperGraphEd;
  127.         hyperGraph -e -showDeformers `optionVar -q hypergraphDisplayDeformers` $hyperGraphEd;
  128.         hyperGraph -e -imageEnabled `optionVar -q hypergraphDisplayImage` $hyperGraphEd;
  129.  
  130.         // Set default state for Orientation preferences
  131.         //
  132.         if (!`optionVar -exists hypergraphOrientation`) {
  133.             optionVar -stringValue hypergraphOrientation "horiz";
  134.         }
  135.         hyperGraph -e -orientation `optionVar -q hypergraphOrientation` $hyperGraphEd;
  136.  
  137.         // Set default state for Layout preferences
  138.         //
  139.         if (!`optionVar -exists hypergraphFreeform`) {
  140.             optionVar -intValue hypergraphFreeform 0;
  141.         }
  142.         hyperGraph -e -freeform `optionVar -q hypergraphFreeform` $hyperGraphEd;
  143.  
  144.         // Set default state for Update preferences
  145.         //
  146.         if (!`optionVar -exists hypergraphUpdateSelection`) {
  147.             optionVar -intValue hypergraphUpdateSelection 1;
  148.         }
  149.         if (!`optionVar -exists hypergraphUpdateNodeAdded`) {
  150.             optionVar -intValue hypergraphUpdateNodeAdded 1;
  151.         }
  152.         hyperGraph -e -updateSelection `optionVar -q hypergraphUpdateSelection` $hyperGraphEd;
  153.         hyperGraph -e -updateNodeAdded `optionVar -q hypergraphUpdateNodeAdded` $hyperGraphEd;
  154.     }
  155.  
  156.     formLayout baseForm;
  157.             frameLayout 
  158.             -visible true 
  159.             -borderVisible false
  160.             -labelVisible false 
  161.             -collapsable false 
  162.             -collapse true
  163.             -borderStyle "in" 
  164.             toolbarFrame;
  165.         string $toolBarForm = `formLayout -visible true toolbarForm`;
  166.         
  167.         //
  168.         // Create quick access buttons which will be hoocked up later, 
  169.         // so they can be in sync with the menu as well as the popupMenu.
  170.         //
  171.         
  172.         int $iconsize = 26;
  173.         
  174.         setParent toolbarForm;
  175.  
  176.             separator -horizontal false -style single hgSeparator1;
  177.  
  178.             iconTextButton
  179.                 -i1 "frameGraph.xpm" 
  180.                 -w $iconsize -h $iconsize
  181.                 -annotation "Frame All"
  182.                 frameGraphButton;
  183.     
  184.             iconTextButton
  185.                 -i1 "frameSelection.xpm" 
  186.                 -w $iconsize -h $iconsize
  187.                 -annotation "Frame Selection"
  188.                 frameSelectionButton;
  189.  
  190.             iconTextButton
  191.                 -i1 "frameHierarchy.xpm" 
  192.                 -w $iconsize -h $iconsize
  193.                 -annotation "Frame Hierarchy"
  194.                 frameHierButton;
  195.             
  196.             iconTextButton 
  197.                 -i1 "frameBranch.xpm" 
  198.                 -w $iconsize -h $iconsize
  199.                 -annotation "Frame Branch"
  200.                 frameBranchButton;
  201.  
  202.             separator -horizontal false -style single hgSeparator2;
  203.  
  204.             iconTextButton
  205.                  -i1 "showDag.xpm" 
  206.                 -w $iconsize -h $iconsize
  207.                  -annotation "Scene Hierarchy"
  208.                  showDAGButton;
  209.  
  210.             iconTextButton
  211.                  -i1 "showDepend.xpm" 
  212.                 -w $iconsize -h $iconsize
  213.                  -annotation "Input and Output Connections"
  214.                  showDGButton;
  215.  
  216.             separator -horizontal false -style single hgSeparator3;
  217.  
  218.             iconTextButton
  219.                 -i1 "addBookmark.xpm" 
  220.                 -w $iconsize -h $iconsize
  221.                 -annotation "Create Bookmark"
  222.                 addBookmarkButton;
  223.  
  224.             iconTextButton
  225.                 -i1 "editBookmark.xpm" 
  226.                 -w $iconsize -h $iconsize
  227.                 -annotation "Bookmark Editor..."
  228.                 editBookmarkButton;
  229.  
  230.             separator -horizontal false -style single hgSeparator4;
  231.     
  232.             iconTextCheckBox 
  233.                 -w $iconsize -h $iconsize
  234.                 -annotation "Toggle Freeform/Automatic Layout Mode"
  235.                 freeformButton;
  236.  
  237.             // Set up the initial value
  238.             if (`hyperGraph -q -freeform $hyperGraphEd`) {
  239.                 iconTextCheckBox -edit
  240.                     -i1 "freeformOn.xpm" 
  241.                     -value true
  242.                     freeformButton;
  243.             } else {
  244.                 iconTextCheckBox -edit
  245.                     -i1 "freeformOff.xpm" 
  246.                     -value false
  247.                     freeformButton;
  248.             }
  249.  
  250.             separator -horizontal false -style single rightSeparator;
  251.  
  252.             string $filterField 
  253.                 = filterUICreateField($hyperGraphEd, $toolBarForm);
  254.             
  255.             formLayout -edit
  256.                 -attachForm    $filterField         "left" 0
  257.  
  258.                 -attachControl hgSeparator1            "left" 0 $filterField
  259.                 -attachForm    hgSeparator1            "top"  1 
  260.                 -attachForm       hgSeparator1            "bottom" 1 
  261.  
  262.                 -attachControl frameGraphButton     "left" 0 hgSeparator1
  263.                 -attachControl frameSelectionButton "left" 0 frameGraphButton
  264.                 -attachControl frameHierButton      "left" 0 frameSelectionButton
  265.                 -attachControl frameBranchButton    "left" 0 frameHierButton
  266.  
  267.                 -attachControl hgSeparator2            "left" 0 frameBranchButton
  268.                 -attachForm    hgSeparator2            "top"  1 
  269.                 -attachForm       hgSeparator2            "bottom" 1 
  270.  
  271.                 -attachControl showDAGButton        "left" 0 hgSeparator2
  272.                 -attachControl showDGButton         "left" 0 showDAGButton
  273.  
  274.                 -attachControl hgSeparator3            "left" 0 showDGButton
  275.                 -attachForm    hgSeparator3            "top"  1 
  276.                 -attachForm       hgSeparator3            "bottom" 1 
  277.  
  278.                 -attachControl addBookmarkButton    "left" 0 hgSeparator3
  279.                 -attachControl editBookmarkButton   "left" 0 addBookmarkButton
  280.  
  281.                 -attachControl hgSeparator4            "left" 0 editBookmarkButton
  282.                 -attachForm    hgSeparator4            "top"  1 
  283.                 -attachForm       hgSeparator4            "bottom" 1 
  284.  
  285.                 -attachControl freeformButton       "left" 0 hgSeparator4
  286.  
  287.                 -attachControl rightSeparator       "left" 0 freeformButton
  288.                 -attachForm    rightSeparator       "top"  1 
  289.                 -attachForm       rightSeparator       "bottom" 1 
  290.                 toolbarForm;
  291.             setParent ..;
  292.     setParent baseForm;        
  293.  
  294.     //
  295.     // Parent the editors to the editor layout
  296.     //
  297.  
  298.     hyperGraph -edit -parent baseForm $hyperGraphEd;
  299.     formLayout -edit
  300.         -attachForm toolbarFrame top 0
  301.         -attachForm toolbarFrame left 0
  302.         -attachForm toolbarFrame right 0
  303.         -attachForm $hyperGraphEd left 0
  304.         -attachForm $hyperGraphEd right 0
  305.         -attachForm $hyperGraphEd bottom 0
  306.         -attachControl $hyperGraphEd top 0 toolbarFrame
  307.         baseForm;
  308.     setParent -top;
  309.  
  310.     //    Attach a procedure that will limit the kinds of filters displayed
  311.     //    in the Hyper Graph's filter menus.
  312.     //
  313.     filterUISetRelatedFiltersProcedure($hyperGraphEd, "hyperGraphFilterCategories");
  314.  
  315.     setUITemplate -popTemplate;
  316.  
  317.     waitCursor -state off;
  318. }
  319.  
  320. global proc removeHyperGraphPanel (string $whichPanel)
  321. //
  322. //  Description:
  323. //        Remove the panel from a layout.
  324. //        Delete controls.
  325. //
  326. {
  327.     string $hyperGraphEd = ($whichPanel + "HyperGraphEd");
  328.  
  329.     if (`hyperGraph -exists $hyperGraphEd`) {
  330.         hyperGraph -edit -unParent $hyperGraphEd;
  331.     }
  332.  
  333.     filterUIRemoveView($hyperGraphEd);
  334. }
  335.  
  336. global proc deleteHyperGraphPanel (string $whichPanel)
  337. //
  338. //  Description:
  339. //        This proc will delete the contents of the panel, but not
  340. //        the panel itself.
  341. //
  342. //  Note:
  343. //        We only need to delete editors here.  Other UI will be taken care of
  344. //        by the remove proc.
  345. //
  346. {
  347.     string $hyperGraphEd = ($whichPanel + "HyperGraphEd");
  348.  
  349.     if (`hyperGraph -exists $hyperGraphEd`) {
  350.         deleteUI -editor $hyperGraphEd;
  351.     }
  352. }
  353.  
  354. global proc string saveStateHyperGraphPanel (string $whichPanel)
  355. //
  356. //  Description:
  357. //        This proc returns a string that when executed will restore the
  358. //        current state of the panel elements.
  359. //
  360. {
  361.     string $indent = "\n\t\t\t";
  362.     string $hyperGraphEd = ($whichPanel + "HyperGraphEd");
  363.  
  364.     return (
  365.             $indent + "$editorName = ($panelName+\"HyperGraphEd\");\n" +
  366.             `hyperGraph -query -stateString $hyperGraphEd`
  367.     );
  368. }
  369.  
  370. global proc hyperGraphPanel (string $panelName)
  371. //
  372. //  Description:
  373. //        Create a new scripted fullGraphPanel.  If the scripted
  374. //        panel hasn't yet been defined then define it.
  375. //
  376. {
  377.     global string $gMainPane;
  378.  
  379.     if (!`scriptedPanelType -exists hyperGraphPanel`) {
  380.         //
  381.         //  Define the callbacks for the hyperGraphPanel
  382.         //
  383.         scriptedPanelType
  384.             -unique true
  385.             -createCallback        "createHyperGraphPanel" 
  386.             -initCallback        "initHyperGraphPanel" 
  387.             -addCallback        "addHyperGraphPanel"
  388.             -removeCallback        "removeHyperGraphPanel"
  389.             -deleteCallback        "deleteHyperGraphPanel"
  390.             -saveStateCallback    "saveStateHyperGraphPanel"
  391.             hyperGraphPanel;
  392.     }
  393.  
  394.     //  instantiate a new hyperGraphPanel
  395.     //
  396.     setParent $gMainPane;
  397.     scriptedPanel -unParent -type hyperGraphPanel $panelName;
  398. }
  399.  
  400. global proc buildHyperGraphContextHelpItems(string $nameRoot, string $menuParent)
  401. //
  402. //  Description:
  403. //        Build context sensitive menu items for the hyper graph.  
  404. //        
  405. //  Input Arguments:
  406. //        $nameRoot - name to use as the root of all item names
  407. //        $menuParent - the name of the parent of this menu
  408. //
  409. //  Return Value:
  410. //      None
  411. //
  412. {
  413.     menuItem -label "Help on Hypergraph..."
  414.         -enableCommandRepeat false
  415.         -command "showHelp Hypergraph";
  416. }
  417.  
  418. global proc string [] hyperGraphFilterCategories()
  419. //
  420. //    Description:
  421. //        Return the types of filters that the Hyper Graph will display
  422. //        in its "Show->Objects" filter menu.
  423. //
  424. {
  425.     string $result[] = { "Modeling", "Camera", "Animating", "Lighting" };
  426.     return $result;
  427. }
  428.